<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>

<html>
<head>
<title>Search books</title>
</head>
<body>
<script type="text/javascript">

function search(page_no){
	$('print_button').setAttribute('page', page_no)
	var url = "<%=request.getContextPath()%>/search_query.htm?" 
	+ $('search_form').serialize()  
	+ '&page_no=' + page_no + '&page_size=<c:out value="${page_size}"/>'
	new Ajax.Updater('search_results', url, { method: 'get' });
}

function printPage(button){
	var page_no = button.getAttribute('page')
	var url = "<%=request.getContextPath()%>/search_query.htm?printable=true&" 
	+ $('search_form').serialize()  
	+ '&page_no=' + page_no + '&page_size=<c:out value="${page_size}"/>'
	window.open(url, "Wydrukuj")
}
</script>
<h1>search books</h1>

<div>
	captcha
</div>

<form action="javascript:search(1)" id="search_form">
	<input type="radio" name="search_type" value="universal_search" checked="checked"> all_fields <br>
	<input type="radio" name="search_type" value="advanced_search" > advanced <br>

	<fieldset >
		<input type="checkbox" name="search_by" value="title" > title <br>
		<input type="checkbox" name="search_by" value="description" > description <br>
		<input type="checkbox" name="search_by" value="tags" > tags <br>
		<input type="checkbox" name="search_by" value="author.name" > author_name <br>
		<input type="checkbox" name="search_by" value="author.surname" > author_surname <br>
		<input type="checkbox" name="userland"  value="rank" > rank <input type="text" name="rank_value"> <br>
	</fieldset>
	
	Search for: <input type="text" name="keywords"/>
	
	<fieldset >
		<input type="radio" name="sort_by"  value="relevance" checked="checked"> relevance<br>
		<input type="radio" name="sort_by" value="id" > id <br>
		<input type="radio" name="sort_by" value="title_forSort" > title <br>
		<input type="radio" name="sort_by" value="description_forSort" > description <br>
		<input type="radio" name="sort_by" value="author.name" > author_name <br>
		<input type="radio" name="sort_by" value="author.surname" > author_surname <br>
		<input type="radio" name="sort_by"  value="rank" > rank<br>
	</fieldset>
	
	<input type="submit" value="Search" ></input>
	<input type="button" value="Print" page="1" id='print_button' onclick='printPage(this)'></input>
</form>

<div id="search_results">
<table>
	<tr>
		<th>id</th>
		<th>rank</th>
		<th>title</th>
		<th>description</th>
		<th>tags</th>
	</tr>

</table>
</div>
<hr>


</body>
</html>

